package com.project.design.algorithm;

import java.awt.image.IndexColorModel;
import java.util.Arrays;

public class InsertionSort {

    public Integer[] insertionSort(Integer[] str) {
        int len = str.length;
        int preIndex;
        Integer current;


        for (int i = 0; i < len; i++) {
            preIndex = i - 1;
            current = str[i];
            while (preIndex >=0 && str[preIndex] > current ){
                str[preIndex + 1] = str[preIndex];
                preIndex--;
            }
            str[preIndex + 1] = current;
        }
        return str;
    }
}
